﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

using QuDao;
using FineUICore;
using Kalman;
using Kalman.Extensions;

namespace AdminUI.Pages.SysManage
{
    public partial class SysUserEditModel : BaseModel
    {
        public void OnGet(int id)
        {
            Current = SysUserBO.Instance.GetItem<SysUser>(id);
            var roleList = RoleBO.Instance.GetList<Role>();

            roleList.Add(new Role { RoleID = -1, RoleName = "超级管理员" });
            ViewBag.RoleList = roleList;

            //var tenant = TenantBO.Instance.GetItem(Current.TID);
            //ViewBag.TenantName = $"{tenant.TenantID}-{tenant.TenantName}";
        }

        public SysUser Current { get; set; }

        public IActionResult OnPostBtnSubmit_Click(SysUserDto dto)
        {
            SysUserBO.Instance.Modify(dto);
            LogAction(ActionType.修改, $"修改用户：{dto.UserID}-{dto.UserName}");

            FineUICore.PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
            //ActiveWindow.HidePostBack();
            return UIHelper.Result();
        }

    }
}